﻿using System;
using System.Data;
using System.Collections.Generic;
using Enterprise.Contract;
using Enterprise.Utility;
using Enterprise.Model;
namespace Enterprise.BLL
{
    /// <summary>
    /// 业务逻辑类Article_Type 的摘要说明。
    /// </summary>
    public class Article_Type : IArticleType
    {
        private readonly Enterprise.Dal.DArticle_Type dal = new Enterprise.Dal.DArticle_Type();
        public Article_Type()
        { }
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ArticleTypeID)
        {
            return dal.Exists(ArticleTypeID);
        }

        /// <summary>
        /// 添加一条数据
        /// </summary>
        public int Add(Enterprise.Model.Article_Type model)
        {
            return dal.Add(model);
        }

        /// <summary>
        ///更新一条数据
        /// </summary>
        public bool Update(Enterprise.Model.Article_Type model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ArticleTypeID)
        {

            return dal.Delete(ArticleTypeID);
        }
        /// <summary>
        ///批量删除
        /// </summary>
        public bool DeleteList(string ArticleTypeIDlist)
        {
            return dal.DeleteList(ArticleTypeIDlist);
        }

        /// <summary>
        ///获取实体 
        /// </summary>
        public Enterprise.Model.Article_Type GetModel(int ArticleTypeID)
        {

            return dal.GetModel(ArticleTypeID);
        }


        /// <summary>
        ///获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        ///获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        ///获得数据列表 
        /// </summary>
        public List<Enterprise.Model.Article_Type> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Enterprise.Model.Article_Type> DataTableToList(DataTable dt)
        {
            List<Enterprise.Model.Article_Type> modelList = new List<Enterprise.Model.Article_Type>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Enterprise.Model.Article_Type model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Enterprise.Model.Article_Type();
                    if (dt.Rows[n]["ArticleTypeID"].ToString() != "")
                    {
                        model.ArticleTypeID = int.Parse(dt.Rows[n]["ArticleTypeID"].ToString());
                    }
                    model.ArticleTypeName = dt.Rows[n]["ArticleTypeName"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }



        #endregion  成员方法
    }
}

